﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/MasterPageAdmin.master" AutoEventWireup="true" CodeFile="Add_pictures.aspx.cs" Inherits="Admin_Add_pictures" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <style type="text/css">
        .style9
        {
            width: 17px;
        }
        .style10
        {
            width: 297px;
            text-align: right;
        }
        .style11
        {
            font-weight: bold;
            color: #66CCFF;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <table class="style7">
        <tr>
            <td colspan="3" style="text-align: center">
                <asp:Label ID="Label1" runat="server" 
                    style="font-size: xx-large; font-weight: 700; color: #CC9900" 
                    Text="Add Pictures"></asp:Label>
            </td>
        </tr>
        <tr>
            <td colspan="3" style="text-align: center">
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style10">
                <asp:Label ID="Label2" runat="server" CssClass="style11" Text="Album ID"></asp:Label>
            </td>
            <td class="style9">
                &nbsp;</td>
            <td>
                <asp:DropDownList ID="ddlAlbumID" runat="server" DataSourceID="SqlDataSource2" 
                    DataTextField="albumId" DataValueField="albumId">
                </asp:DropDownList>
                <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                    SelectCommand="SELECT [albumId] FROM [tblAlbum]"></asp:SqlDataSource>
            </td>
        </tr>
        <tr>
            <td class="style10">
                <asp:Label ID="Label3" runat="server" CssClass="style11" Text="Caption"></asp:Label>
            </td>
            <td class="style9">
                &nbsp;</td>
            <td>
                <asp:TextBox ID="txtCaption" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style10">
                <asp:Label ID="Label4" runat="server" CssClass="style11" Text="File path"></asp:Label>
            </td>
            <td class="style9">
                &nbsp;</td>
            <td>
                <asp:FileUpload ID="FileUpload" runat="server" />
            </td>
        </tr>
        <tr>
            <td class="style10" valign="top">
                <asp:Label ID="Label5" runat="server" CssClass="style11" Text="Upload date"></asp:Label>
            </td>
            <td class="style9">
                &nbsp;</td>
            <td>
                <asp:Calendar ID="cldDate" runat="server"></asp:Calendar>
            </td>
        </tr>
        <tr>
            <td class="style10">
                <asp:Label ID="Label6" runat="server" CssClass="style11" Text="Upload ID"></asp:Label>
            </td>
            <td class="style9">
                &nbsp;</td>
            <td>
                <asp:DropDownList ID="ddlID" runat="server">
                    <asp:ListItem></asp:ListItem>
                    <asp:ListItem Value="1">Administartor</asp:ListItem>
                    <asp:ListItem Value="2">Staff</asp:ListItem>
                    <asp:ListItem Value="4">Upload</asp:ListItem>
                </asp:DropDownList>
            </td>
        </tr>
        <tr>
            <td class="style10">
                &nbsp;</td>
            <td class="style9">
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style10">
                <asp:Label ID="lblMsg" runat="server" style="color: #FF3300; font-size: medium"></asp:Label>
            </td>
            <td class="style9">
                &nbsp;</td>
            <td>
                <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Add" />
            </td>
        </tr>
        <tr>
            <td class="style10">
                &nbsp;</td>
            <td class="style9">
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style10">
                <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                    DeleteCommand="DELETE FROM [tblPicture] WHERE [pictureId] = @pictureId" 
                    InsertCommand="INSERT INTO [tblPicture] ([albumId], [caption], [filePath], [uploadedDate], [uploadedUserId]) VALUES (@albumId, @caption, @filePath, @uploadedDate, @uploadedUserId)" 
                    SelectCommand="SELECT * FROM [tblPicture]" 
                    UpdateCommand="UPDATE [tblPicture] SET [albumId] = @albumId, [caption] = @caption, [filePath] = @filePath, [uploadedDate] = @uploadedDate, [uploadedUserId] = @uploadedUserId WHERE [pictureId] = @pictureId">
                    <DeleteParameters>
                        <asp:Parameter Name="pictureId" Type="Int32" />
                    </DeleteParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="albumId" Type="Int32" />
                        <asp:Parameter Name="caption" Type="String" />
                        <asp:Parameter Name="filePath" Type="String" />
                        <asp:Parameter Name="uploadedDate" Type="DateTime" />
                        <asp:Parameter Name="uploadedUserId" Type="Int32" />
                        <asp:Parameter Name="pictureId" Type="Int32" />
                    </UpdateParameters>
                    <InsertParameters>
                        <asp:ControlParameter ControlID="ddlAlbumID" Name="albumId" 
                            PropertyName="SelectedValue" Type="Int32" />
                        <asp:ControlParameter ControlID="txtCaption" Name="caption" PropertyName="Text" 
                            Type="String" />
                        <asp:ControlParameter ControlID="FileUpload" Name="filePath" 
                            PropertyName="FileName" Type="String" />
                        <asp:ControlParameter ControlID="cldDate" Name="uploadedDate" 
                            PropertyName="SelectedDate" Type="DateTime" />
                        <asp:ControlParameter ControlID="ddlID" Name="uploadedUserId" 
                            PropertyName="SelectedValue" Type="Int32" />
                    </InsertParameters>
                </asp:SqlDataSource>
            </td>
            <td class="style9">
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
    </table>
</asp:Content>

